/*
   Copyright (c) 2023 李伟国
   learner-platform is licensed under Mulan PSL v2.
   You can use this software according to the terms and conditions of the Mulan PSL v2. 
   You may obtain a copy of Mulan PSL v2 at:
               http://license.coscl.org.cn/MulanPSL2 
   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.  
   See the Mulan PSL v2 for more details. 
*/

package cn.platform.service;

import cn.platform.dto.CodeRunMsg;
import cn.platform.dto.CodeRunResult;
import cn.platform.dto.TestInOutDto;
import cn.platform.entity.Problem;
import cn.platform.entity.Runner;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

public interface IProblemService extends IService<Problem> {
    /**
     * 保存题目
     * @param problem 题目
     * @return 是否保存成功
     */
    int saveDraft(Problem problem);

    /**
     * 保存并发布题目
     * @param problem 题目
     * @return 结果
     */
    int saveRelease(Problem problem);


    /**
     * 保存用于判题的代码
     * @param codeRunMsg 代码信息
     * @return 创建的id
     */
    Long saveTestCode(CodeRunMsg codeRunMsg);

    /**
     * 保存测试用例
     *
     * @param testInOutDto 测试用例
     * @return 是否保存成功
     */
    boolean saveTestCase(TestInOutDto testInOutDto);

    /**
     * 保存测试样例
     *
     * @param testInOutDto 测试样例
     * @return 是否保存成功
     */
    boolean saveTestSample(TestInOutDto testInOutDto);

    /**
     * 执行测试样例
     * @param runner 题目运行条件
     * @return 运行结果
     */
    CodeRunResult runTestCode(Runner runner);

    /**
     * 测试代码判题
     * @param userId 用户id
     * @param runner 题目运行条件
     * @return 运行结果
     */
    CodeRunResult runUserCode(Long userId, Runner runner);

    /**
     * 查询题目列表
     * @param id 题目id
     * @param title 题目标题
     * @param label 标签
     * @return 列表
     */
    Page<Problem> getProblemByIdAndTitleAndLabels(Integer id, String title, String label);
}
